/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */
/**
 * @param {ListNode} head
 * @return {boolean}
 */
 var isPalindrome = function(head) {
    if(!head || head.next==null){
        return true;
    }
    let first,end;
    let arr=[];
    while(head!=null){
        arr.push(head.val);
        head=head.next;
    }
    first=0;
    end=arr.length-1;
    while(first<end){
        if(arr[first]!=arr[end]){
            return false;
        }
        first++;
        end--;
    }
    return true;
};